package org.jetlinks.pro.tdengine.device;

import org.jetlinks.core.device.DeviceRegistry;
import org.jetlinks.pro.device.service.data.DeviceDataStoragePolicy;
import org.jetlinks.pro.device.service.data.DeviceDataStorageProperties;
import org.jetlinks.pro.tdengine.TDengineRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass(DeviceDataStoragePolicy.class)
@ConditionalOnProperty(prefix = "tdengine", value = "enabled", havingValue = "true")
public class TDengineDeviceDataStoreConfiguration {

    @Bean
    public TDengineDeviceDataColumnStoragePolicy tDengineDeviceDataColumnStoragePolicy(DeviceRegistry registry,
                                                                                       TDengineRepository repository,
                                                                                       DeviceDataStorageProperties properties) {
        return new TDengineDeviceDataColumnStoragePolicy(
            registry,
            repository,
            properties
        );
    }
}